module dgl.Vector2;

import str = std.string;

struct Vector2
{
	private float[2] m_vector;
	
	public float x()
	{
		return m_vector[0];
	}
	
	public float y()
	{
		return m_vector[1];
	}
	
	public void x( float x )
	{
		m_vector[0] = x;
	}
	
	public void y( float y )
	{
		m_vector[1] = y;
	}
	
	public float * ptr()
	{
		return m_vector.ptr;
	}
	
	public static Vector2 opCall( float x, float y )
	{
		Vector2 ret;
		ret.x = x;
		ret.y = y;
		return ret;
	}
	
	public static Vector2 opCall( float value )
	{
		Vector2 ret;
		ret.x = value;
		ret.y = value;
		return ret;
	}
	
	public static Vector2 zero()
	{
		return Vector2( 0, 0 );
	}
	
	public string toString()
	{
		string ret = "";
		ret ~= "{ " ~ str.toString( x );
		ret ~= ", " ~ str.toString( y );
		ret ~= " }";
		return ret;
	}
}